import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:tiktokadult/hj_page/cartoon_business/widget/acg_source_manager.dart';

//有声小说logic
class VoiceNovelReadLogic extends GetxController with GetSingleTickerProviderStateMixin {
  bool isFirstLoad = true;
  late String id;
  String? title;
  AudioPlayerManager audioManager = AudioPlayerManager(); //播放器管理
  late ACGSourceManager sourceManager; //资源管理
  final tabs = ['相关推荐', '评论'];
  late TabController tabCtr = TabController(length: tabs.length, vsync: this);

  late int index;

  VoiceNovelReadLogic();

  onInit() {
    super.onInit();
    audioManager.initPlayer();
    final arguments = Get.arguments;
    sourceManager = arguments['manager'];
    index = arguments['index'];
    title = arguments['title'] ?? '';
    id = arguments['id'];
    audioManager.sourceManger = sourceManager;
    sourceManager.index = index;
  }

  // 所有播放地址
  @override
  void onReady() {
    super.onReady();
    isFirstLoad = false;
    update();
  }

  @override
  onClose() {
    print('dispose ===== VoiceNovelReadLogic');
    super.onClose();
    audioManager.dispose();
  }
}
